<template>
    <el-table align="center" :data="cartData" style="width: 100%">
        <el-table-column prop="goodName" label="商品名称">
        </el-table-column>
        <el-table-column prop="content" label="商品描述">
        </el-table-column>
        <el-table-column prop="price" label="商品价格">
        </el-table-column>
        <el-table-column prop="operation" label="操作">
            <template slot-scope="scope">
                <el-button @click="delGood(scope.row)" type="text" size="small">删除</el-button>
                <el-button @click="insertGood(scope.row)" type="text" size="small">下单</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
import Service from '@/service/request'
// import { async } from 'q'

export default {
    data() {
        return {
            cartData: []
        }
    },
    methods: {
        async delGood(data) {
            await Service.delCartData(this.$store.state.userId, data.goodId, data.id)
            this.cartData = await Service.getCartData(this.$store.state.userId)
        },
        async insertGood(data) {
            await Service.insertOrder(this.$store.state.userId, data.goodId, data.id)
            this.cartData = await Service.getCartData(this.$store.state.userId)
        }
    },
    async created() {
        this.cartData = await Service.getCartData(this.$store.state.userId)
        console.log("this.cartData >>>", this.cartData)
    }
}
</script>

<style>

</style>